package com.example.ssm.service.impl;

import com.example.ssm.entity.Student;
import com.example.ssm.mapper.StudentDao;
import com.example.ssm.service.StudentServiceStrong;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class StudentServiceStrongImpl implements StudentServiceStrong {

    @Autowired
    public StudentServiceStrongImpl(StudentDao studentDao) {
        this.studentDao = studentDao;
    }

    @Autowired
    private StudentDao studentDao;

    @Override
    @Transactional(propagation = Propagation.REQUIRES_NEW,isolation = Isolation.READ_COMMITTED)
    public int updateById(Student student) {
        return studentDao.updateByPrimaryKeySelective(student);
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS,isolation = Isolation.READ_COMMITTED)
    public Student getById(String id) {
        return studentDao.selectByPrimaryKey(id);
    }


}
